class Entry < ActiveRecord::Base
  belongs_to  :record
  belongs_to  :income
  belongs_to  :expense

  before_save :entry_balance
  after_save  :account_balance

  private
  def entry_balance
    self.balance = self.record.account.balance + self.amount
  end
    
  def account_balance
    self.record.account.balance = self.balance
    self.record.account.save
  end
end
